
/*以下代码是实现自动显示当前日期的功能函数*/

function today() {
    var today = new Date();
    var h = today.getFullYear();
    var m = today.getMonth() + 1;
    var d = today.getDate();
    m = m < 10 ? "0" + m : m; //  这里判断月份是否<10,如果是在月份前面加'0'
    d = d < 10 ? "0" + d : d; //  这里判断日期是否<10,如果是在日期前面加'0'
    return h + "-" + m + "-" + d;
}
document.getElementById("startDate").value = today(); //获取文本id并且传入当前日期



//结束的代码同上

function tomorrow() {
    var tomorrow = new Date();
    var h_tomorrow = tomorrow.getFullYear();
    var m_tomorrow = tomorrow.getMonth() + 1;
    var d_tomorrow = tomorrow.getDate() + 1;
    m_tomorrow = m_tomorrow < 10 ? "0" + m_tomorrow : m_tomorrow;
    d_tomorrow = d_tomorrow < 10 ? "0" + d_tomorrow : d_tomorrow;
    return h_tomorrow + "-" + m_tomorrow + "-" + d_tomorrow;
}
document.getElementById("endDate").value = tomorrow();